home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / mac / Road Construction Ahead / Road Construction Ahead / 00022_DitchClass.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  5.9 KB  |  235 lines

  1. property state, bucketFull, bucketChan, emptyBucket, dirtLoads, centerVertList, rightVertList, horizList, firstArrowChan, buttonData, patchChan, firstPatch, dirtChan, sandboxChan
  2. global gTruckObject, gSimObject, gLevelObject
  3.  
  4. on birth me
  5.   set state to 1
  6.   set bucketFull to 0
  7.   set dirtLoads to 0
  8.   set patchChan to 4
  9.   set bucketChan to 5
  10.   set dirtChan to 6
  11.   set firstArrowChan to 7
  12.   set sandboxChan to 27
  13.   set centerVertList to [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]
  14.   set rightVertList to [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1]
  15.   set horizList to [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1]
  16.   set buttonData to [1: [0, 1, 1, 1], 2: [0, 1, 0, 0], 3: [1, 0, 0, 0], 4: [0, 0, 1, 1], 5: [1, 0, 0, 0]]
  17.   return me
  18. end
  19.  
  20. on setup me
  21.   add(gActorList, birth(script "Rollover Anim Button Class", "goMenu( gDitchObject, me )", 27, 27, 5, "RCA-07VO01", "RCA-07RO01"))
  22.   add(gActorList, birth(script "Rollover Anim Button Class", "help( gDitchObject, me )", 28, 28, 11, EMPTY, "RCA-05RO02"))
  23.   puppetSprite(bucketChan, 1)
  24.   puppetSprite(patchChan, 1)
  25.   puppetSprite(dirtChan, 1)
  26.   set the visible of sprite firstArrowChan to 0
  27.   set emptyBucket to the castNum of sprite bucketChan
  28.   set firstPatch to the castNum of sprite patchChan
  29. end
  30.  
  31. on upButton me
  32.   if state = 3 then
  33.     buttonSound(me)
  34.     repeat with delta in centerVertList
  35.       moveVert(me, -1 * delta)
  36.     end repeat
  37.     set state to 1
  38.   else
  39.     if state = 5 then
  40.       buttonSound(me)
  41.       repeat with delta in rightVertList
  42.         moveVert(me, -1 * delta)
  43.       end repeat
  44.       set state to 4
  45.     end if
  46.   end if
  47.   updateButtons(me)
  48. end
  49.  
  50. on downButton me
  51.   if state = 1 then
  52.     buttonSound(me)
  53.     repeat with delta in centerVertList
  54.       moveVert(me, delta)
  55.     end repeat
  56.     if bucketFull then
  57.       depositDirt(me)
  58.     end if
  59.     set state to 3
  60.     updateButtons(me)
  61.   else
  62.     if state = 4 then
  63.       buttonSound(me)
  64.       repeat with delta in rightVertList
  65.         moveVert(me, delta)
  66.       end repeat
  67.       fillBucket(me)
  68.       set state to 5
  69.       go(the frame)
  70.       updateButtons(me)
  71.     end if
  72.   end if
  73. end
  74.  
  75. on depositDirt me
  76.   set dirtLoads to dirtLoads + 1
  77.   set the castNum of sprite patchChan to firstPatch + dirtLoads - 1
  78.   set the locH of sprite patchChan to 320
  79.   puppetSound("1030dump")
  80.   emptyBucket(me)
  81.   puppetTransition(51, 1)
  82.   go(the frame)
  83.   if dirtLoads = 3 then
  84.     finishedGame(me)
  85.   end if
  86. end
  87.  
  88. on finishedGame me
  89.   startTimer()
  90.   repeat while the timer < 30
  91.   end repeat
  92.   puppetSound(0)
  93.   puppetSound("1030cheer")
  94.   set the castNum of sprite patchChan to firstPatch + dirtLoads
  95.   puppetTransition(51, 1)
  96.   go(the frame)
  97.   set state to 1
  98.   set bucketFull to 0
  99.   set dirtLoads to 0
  100.   repeat with button = 1 to 4
  101.     set the visible of sprite (firstArrowChan + button - 1) to 1
  102.   end repeat
  103.   set the tileNum of the blockedCellObj of gTruckObject to 0
  104.   set the tileType of the blockedCellObj of gTruckObject to #BG
  105.   set x to blockCrossings(the cell of gTruckObject, getLast(the recordedMoveList of gSimObject))
  106.   finishSound(me)
  107.   clearAllActors()
  108.   puppetSprite(bucketChan, 0)
  109.   puppetSprite(patchChan, 0)
  110.   puppetSprite(dirtChan, 0)
  111.   keepSandboxBut(sandboxChan)
  112.   puppetPalette("DitchPal")
  113.   go("Grass")
  114.   puppetSprite(48, 0)
  115.   puppetPalette("SimPal")
  116.   predrawSimButtons(gSimObject)
  117.   go(label("Simulator" & string(the level of gLevelObject)))
  118.   abort()
  119. end
  120.  
  121. on fillBucket me
  122.   set bucketFull to 1
  123.   set the castNum of sprite bucketChan to emptyBucket + 1
  124.   if dirtLoads = 2 then
  125.     set the locH of sprite dirtChan to 1000
  126.   end if
  127.   puppetTransition(51, 1)
  128. end
  129.  
  130. on emptyBucket me
  131.   set bucketFull to 0
  132.   set the castNum of sprite bucketChan to emptyBucket
  133. end
  134.  
  135. on rightButton me
  136.   if state = 2 then
  137.     buttonSound(me)
  138.     repeat with delta in horizList
  139.       moveHoriz(me, delta)
  140.     end repeat
  141.     set state to 1
  142.   else
  143.     if state = 1 then
  144.       buttonSound(me)
  145.       repeat with delta in horizList
  146.         moveHoriz(me, delta)
  147.       end repeat
  148.       set state to 4
  149.     end if
  150.   end if
  151.   updateButtons(me)
  152. end
  153.  
  154. on leftButton me
  155.   if state = 1 then
  156.     buttonSound(me)
  157.     repeat with delta in horizList
  158.       moveHoriz(me, -1 * delta)
  159.     end repeat
  160.     set state to 2
  161.   else
  162.     if state = 4 then
  163.       buttonSound(me)
  164.       repeat with delta in horizList
  165.         moveHoriz(me, -1 * delta)
  166.       end repeat
  167.       set state to 1
  168.     end if
  169.   end if
  170.   updateButtons(me)
  171. end
  172.  
  173. on buttonSound me
  174.   puppetSound("arrowClick")
  175.   updateStage()
  176.   finishSound(me)
  177.   puppetSound("1030machine")
  178. end
  179.  
  180. on moveVert me, delta
  181.   startTimer()
  182.   set the locV of sprite bucketChan to the locV of sprite bucketChan + delta
  183.   moveSprites(me)
  184. end
  185.  
  186. on moveHoriz me, delta
  187.   startTimer()
  188.   set the locH of sprite bucketChan to the locH of sprite bucketChan + delta
  189.   moveSprites(me)
  190. end
  191.  
  192. on finishSound me
  193.   repeat while soundBusy(1)
  194.   end repeat
  195.   puppetSound(0)
  196. end
  197.  
  198. on updateButtons me
  199.   set buttonList to getProp(buttonData, state)
  200.   repeat with button = 1 to count(buttonList)
  201.     set boolean to getAt(buttonList, button)
  202.     set the visible of sprite (firstArrowChan + button - 1) to boolean
  203.   end repeat
  204.   finishSound(me)
  205. end
  206.  
  207. on moveSprites me
  208.   repeat while the timer < 2
  209.   end repeat
  210.   updateStage()
  211. end
  212.  
  213. on goMenu me, buttonObject
  214.   forgetObstacle(gSimObject)
  215.   set state to 1
  216.   set bucketFull to 0
  217.   set dirtLoads to 0
  218.   clearAllActors()
  219.   unpuppetAll()
  220.   makeButtonJump(buttonObject)
  221.   puppetSprite(48, 0)
  222.   puppetPalette("DitchPal")
  223.   go("Grass")
  224.   repeat with button = 1 to 4
  225.     set the visible of sprite (firstArrowChan + button - 1) to 1
  226.   end repeat
  227.   puppetPalette("MainPal")
  228.   unLoadCast()
  229.   goLocationMap()
  230. end
  231.  
  232. on help me, buttonObject
  233.   birth(script "Help Parent", buttonObject, #Ditch)
  234. end
  235.